package com.gin.kotlin.no_gay_alliance.adapter.reply

import android.content.Context
import com.gin.kotlin.no_gay_alliance.activity.ReplyListActivity
import com.gin.kotlin.no_gay_alliance.argument.ReplyListArgument
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingRecyclerViewAdapter
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemEditHisitoryBinding
import com.gin.kotlin.no_gay_alliance.store.GlobalProperty
import com.gin.kotlin.no_gay_alliance.utils.TimeUtils
import com.gin.nga.response.reply.EditHistory

class EditHistoryAdapter(context: Context, handler: MyHandler) : AbstractBindingRecyclerViewAdapter<ItemEditHisitoryBinding, EditHistory>(context, handler) {
    override fun onBindViewHolder(holder: ViewHolder<ItemEditHisitoryBinding>, position: Int, b: ItemEditHisitoryBinding, dataModel: EditHistory) {
        val tv = b.tvText
        val time = TimeUtils.FULL_DATE_TIME_FORMATTER.format(dataModel.before)
        tv.text = "$time 前"
        tv.textSize = 20.0F

        val url = dataModel.url?.substring(1).let { "https://${GlobalProperty.getInstance().domain.host}$it" }
        tv.tag = url
        tv.setOnClickListener { ReplyListActivity.startActivity(context, ReplyListArgument.parseUrl(it.tag.toString())!!) }
    }
}